local joy__xuhe = fk.CreateSkill {

  name = "joy__xuhe",

  tags = { Skill.Compulsory, },

}



joy__xuhe:addEffect(fk.CardEffectCancelledOut, {
  name = "joy__xuhe",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardEffectCancelledOut, fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if event == fk.CardEffectCancelledOut then
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.trueName == "slash"
    else
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.name == "jink"
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, joy__xuhe.name)
    if event == fk.CardEffectCancelledOut then
      local tar = player.room:getPlayerById(data.to)
      if not tar.dead then
        tar:drawCards(1,joy__xuhe.name)
      end
    end
  end,
})
joy__xuhe:addEffect(fk.CardUsing, {
  name = "joy__xuhe",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardEffectCancelledOut, fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if event == fk.CardEffectCancelledOut then
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.trueName == "slash"
    else
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.name == "jink"
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, joy__xuhe.name)
    if event == fk.CardEffectCancelledOut then
      local tar = player.room:getPlayerById(data.to)
      if not tar.dead then
        tar:drawCards(1,joy__xuhe.name)
      end
    end
  end,
})
joy__xuhe:addEffect(fk.CardResponding, {
  name = "joy__xuhe",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardEffectCancelledOut, fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if event == fk.CardEffectCancelledOut then
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.trueName == "slash"
    else
      return target == player and player:hasSkill(joy__xuhe.name) and data.card.name == "jink"
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, joy__xuhe.name)
    if event == fk.CardEffectCancelledOut then
      local tar = player.room:getPlayerById(data.to)
      if not tar.dead then
        tar:drawCards(1,joy__xuhe.name)
      end
    end
  end,
})

return joy__xuhe